package com.xqls.biz.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import com.xqls.bean.DischargeRealdataBean;
import com.xqls.bean.PublicStormwaterRealdataBean;
import com.xqls.bean.RainwaterDischargeRealdataBean;
import com.xqls.biz.AlarmBiz;
import com.xqls.biz.DictionaryBiz;
import com.xqls.dal.model.Dictionary;
import com.xqls.util.DictionaryEnums;

public class SendMessageBizImpl {
	
	private static Logger logger = Logger.getLogger(MessageBizImpl.class);

	@Autowired private DictionaryBiz dictionaryBiz;
	@Autowired private AlarmBiz alarmBiz;
	
	private List<Integer> levelList = LevelTypeList();
	
	/**
	 * 获取枚举code集合
	 * @return
	 */
	private List<Integer> getList(){
		List<Integer> list = new ArrayList<Integer>();
		list.add(DictionaryEnums.VALUE.getCode());
		list.add(DictionaryEnums.MAINS.getCode());
		list.add(DictionaryEnums.NETWORK.getCode());
		list.add(DictionaryEnums.LIQUID_SITE.getCode());
		list.add(DictionaryEnums.DOOR.getCode());
		return list;
	}
	
	/**
	 * 获取选中的报警类型集合
	 * @return
	 */
	private List<Integer> LevelTypeList(){
		List<Integer> levelList = getList();
		List<Integer> typeList = new ArrayList<Integer>();
		try {
			List<Dictionary> levels = dictionaryBiz.getListByKeys(levelList);
			for (Dictionary dictionary : levels) {
				if("yes".equals(dictionary.getDictionaryValue())){
					typeList.add(dictionary.getDictionaryKey());
				}
			}
		} catch (Exception e) {
			logger.error("批量查询字典异常",e);
		}
		return typeList;
	}
	
	/**
	 * 查询取水口电源异常情况
	 * @return
	 */
	public void queryQskDyNetData(){
		List<DischargeRealdataBean> list = new ArrayList<DischargeRealdataBean>();
		// TODO 东东 查询状态是异常的实时数据
		for (Integer integer : levelList) {
			if(integer == DictionaryEnums.MAINS.getCode()){
				for (DischargeRealdataBean bean : list) {
					alarmBiz.sendMessage(bean.getDeviceNo(), integer, DictionaryEnums.MAINS);
				}
			}
		}
	}
	
	/**
	 * 查询取水口阀门异常情况
	 * @return
	 */
	public void queryQskFmNetData(){
		List<DischargeRealdataBean> list = new ArrayList<DischargeRealdataBean>();
		// TODO 东东 查询状态是异常的实时数据
		for (Integer integer : levelList) {
			if(integer == DictionaryEnums.VALUE.getCode()){
				for (DischargeRealdataBean bean : list) {
					alarmBiz.sendMessage(bean.getDeviceNo(), integer, DictionaryEnums.VALUE);
				}
			}
		}
	}
	
	/**
	 * 查询取水口监测房门异常情况
	 * @return
	 */
	public void queryQskJcfmNetData(){
		List<DischargeRealdataBean> list = new ArrayList<DischargeRealdataBean>();
		// TODO 东东 查询状态是异常的实时数据
		for (Integer integer : levelList) {
			if(integer == DictionaryEnums.DOOR.getCode()){
				for (DischargeRealdataBean bean : list) {
					alarmBiz.sendMessage(bean.getDeviceNo(), integer, DictionaryEnums.DOOR);
				}
			}
		}
	}
	
	/**
	 * 查询取水口监网络异常情况
	 * @return
	 */
	public void queryQskWlNetData(){
		List<DischargeRealdataBean> list = new ArrayList<DischargeRealdataBean>();
		// TODO 东东 查询状态是异常的实时数据
		for (Integer integer : levelList) {
			if(integer == DictionaryEnums.NETWORK.getCode()){
				for (DischargeRealdataBean bean : list) {
					alarmBiz.sendMessage(bean.getDeviceNo(), integer, DictionaryEnums.NETWORK);
				}
			}
		}
	}
	
	/**
	 * 查询公共雨水排放口监网络异常情况
	 * @return
	 */
	public void queryYsWlNetData(){
		List<PublicStormwaterRealdataBean> list = new ArrayList<PublicStormwaterRealdataBean>();
		// TODO 东东 查询状态是异常的实时数据
		for (Integer integer : levelList) {
			if(integer == DictionaryEnums.NETWORK.getCode()){
				for (PublicStormwaterRealdataBean bean : list) {
					alarmBiz.sendMessage(bean.getDeviceNo(), integer, DictionaryEnums.NETWORK);
				}
			}
		}
	}
	
	/**
	 * 查询公共雨水排放口监电源异常情况
	 * @return
	 */
	public void queryYsDyNetData(){
		List<PublicStormwaterRealdataBean> list = new ArrayList<PublicStormwaterRealdataBean>();
		// TODO 东东 查询状态是异常的实时数据
		for (Integer integer : levelList) {
			if(integer == DictionaryEnums.MAINS.getCode()){
				for (PublicStormwaterRealdataBean bean : list) {
					alarmBiz.sendMessage(bean.getDeviceNo(), integer, DictionaryEnums.MAINS);
				}
			}
		}
	}
	
	/**
	 * 查询公共雨水排放口监测房门异常情况
	 * @return
	 */
	public void queryYsJcfmNetData(){
		List<PublicStormwaterRealdataBean> list = new ArrayList<PublicStormwaterRealdataBean>();
		// TODO 东东 查询状态是异常的实时数据
		for (Integer integer : levelList) {
			if(integer == DictionaryEnums.DOOR.getCode()){
				for (PublicStormwaterRealdataBean bean : list) {
					alarmBiz.sendMessage(bean.getDeviceNo(), integer, DictionaryEnums.DOOR);
				}
			}
		}
	}
	
	/**
	 * 查询公共雨水排放口阀门异常情况
	 * @return
	 */
	public void queryYsFmNetData(){
		List<PublicStormwaterRealdataBean> list = new ArrayList<PublicStormwaterRealdataBean>();
		// TODO 东东 查询状态是异常的实时数据
		for (Integer integer : levelList) {
			if(integer == DictionaryEnums.VALUE.getCode()){
				for (PublicStormwaterRealdataBean bean : list) {
					alarmBiz.sendMessage(bean.getDeviceNo(), integer, DictionaryEnums.VALUE);
				}
			}
		}
	}
	
	/**
	 * 查询企业雨水排放口监网络异常情况
	 * @return
	 */
	public void queryQyYsWlNetData(){
		List<RainwaterDischargeRealdataBean> list = new ArrayList<RainwaterDischargeRealdataBean>();
		// TODO 东东 查询状态是异常的实时数据
		for (Integer integer : levelList) {
			if(integer == DictionaryEnums.NETWORK.getCode()){
				for (RainwaterDischargeRealdataBean bean : list) {
					alarmBiz.sendMessage(bean.getDeviceNo(), integer, DictionaryEnums.NETWORK);
				}
			}
		}
	}
	
	/**
	 * 查询企业雨水排放口监电源异常情况
	 * @return
	 */
	public void queryQyYsDyNetData(){
		List<RainwaterDischargeRealdataBean> list = new ArrayList<RainwaterDischargeRealdataBean>();
		// TODO 东东 查询状态是异常的实时数据
		for (Integer integer : levelList) {
			if(integer == DictionaryEnums.MAINS.getCode()){
				for (RainwaterDischargeRealdataBean bean : list) {
					alarmBiz.sendMessage(bean.getDeviceNo(), integer, DictionaryEnums.MAINS);
				}
			}
		}
	}
	
	/**
	 * 查询企业雨水排放口监测房门异常情况
	 * @return
	 */
	public void queryQyYsJcfmNetData(){
		List<RainwaterDischargeRealdataBean> list = new ArrayList<RainwaterDischargeRealdataBean>();
		// TODO 东东 查询状态是异常的实时数据
		for (Integer integer : levelList) {
			if(integer == DictionaryEnums.DOOR.getCode()){
				for (RainwaterDischargeRealdataBean bean : list) {
					alarmBiz.sendMessage(bean.getDeviceNo(), integer, DictionaryEnums.DOOR);
				}
			}
		}
	}
	
	/**
	 * 查询企业雨水排放口阀门异常情况
	 * @return
	 */
	public void queryQyYsFmNetData(){
		List<RainwaterDischargeRealdataBean> list = new ArrayList<RainwaterDischargeRealdataBean>();
		// TODO 东东 查询状态是异常的实时数据
		for (Integer integer : levelList) {
			if(integer == DictionaryEnums.VALUE.getCode()){
				for (RainwaterDischargeRealdataBean bean : list) {
					alarmBiz.sendMessage(bean.getDeviceNo(), integer, DictionaryEnums.VALUE);
				}
			}
		}
	}
	
	/**
	 * 查询企业雨水排放口液位异常情况
	 * @return
	 */
	public void queryQyYwYwNetData(){
		List<RainwaterDischargeRealdataBean> list = new ArrayList<RainwaterDischargeRealdataBean>();
		// TODO 东东 查询状态是异常的实时数据
		for (Integer integer : levelList) {
			if(integer == DictionaryEnums.LIQUID_SITE.getCode()){
				for (RainwaterDischargeRealdataBean bean : list) {
					alarmBiz.sendMessage(bean.getDeviceNo(), integer, DictionaryEnums.ALARM);
				}
			}
		}
	}
}
